#!/bin/bash

# cd to correct path:
result=${PWD##*/}
result="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
result=$(cd "$(dirname "$0")"; pwd)
cd $result
cd ..
cd source
echo 'current path:'
echo '-------------'
pwd

echo 'delete all migration files:'
echo '---------------------------'
find . -path *migrations* -name "*.py" -not -path "*__init__*"
find . -path *migrations* -name "*.py" -not -path "*__init__*" -exec rm {} \;

echo 'delete .sqlite3'
echo '---------------'
rm ../database/db.sqlite3

echo 'makemigrations and migrate'
echo '--------------------------'
python manage.py makemigrations
python manage.py migrate

echo 'initialize db'
echo '-------------'
python manage.py initdb
